package com.example.ojbackenduserservice.controller.inner;

import com.example.ojbackendcommon.common.ErrorCode;
import com.example.ojbackendcommon.exception.BusinessException;
import com.example.ojbackendmodel.model.entity.User;
import com.example.ojbackendmodel.model.enums.UserRoleEnum;
import com.example.ojbackendmodel.model.vo.UserVO;
import com.example.ojbackendserviceclient.service.UserFeignClient;
import com.example.ojbackenduserservice.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;

import static com.example.ojbackendcommon.constant.UserConstant.USER_LOGIN_STATE;

@RestController
@RequestMapping("/inner")
public class UserInnerController implements UserFeignClient {
    @Resource
    private UserService userService;
    /*
     根据userId获取当前用户
    */
    @Override
    @GetMapping("/get/id")
    public User getById(@RequestParam("userId") long userId){
          return userService.getById(userId);
    }

    /*
      根据userId获取用户列表
     */
    @Override
    @GetMapping("/get/ids")
   public List<User> listByIds(@RequestParam("idList") Collection<Long> idList){
          return userService.listByIds(idList);
    }
}
